package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.entity.Student;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *springboot整合mybatis，需要在mapper接口上添加@Mapper注解，否则接口不能有效识别
 */
@Mapper
public interface StudentMapper {

    // 增加
    @Insert("insert into student1(id,name,age) values (#{id},#{name},#{age})")
    void insert(Student s);
    // 删除
    @Delete("delete from student1 where id=#{id}")
    void delete(String id);
    // 修改
    @Update("update student1 set name=#{name},age=#{age} where id=#{id}")
    void update(Student s);
    // 根据id查单条
    @Select("select * from student1 where id=#{id}")
    Student getById(String id);
    // 查询全部
    @Select("select * from student1")
    List<Student> getAll();
}
